using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace DailyTransaction
{
    public partial class frmRcpt : Form
    {
        private BAO_Rcpt bao = new BAO_Rcpt();
        public frmRcpt()
        {
            InitializeComponent();
        }

        private void InputReceptionistForm_Load(object sender, EventArgs e)
        {
            txtRcptID.Text = get_newID();
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtRcptname.Text.Trim() == "")
            {
                MessageBox.Show("Please input receptionist's name!");
                txtRcptname.Focus();
                return;
            }
            int rslt = bao.insert_new_receptionist(txtRcptID.Text, txtRcptname.Text.Trim());
            if (rslt > 0)
            {
                MessageBox.Show("Saved successfull!");
                txtRcptID.Text = get_newID();
                txtRcptname.Text = "";
                txtRcptname.Focus();
            }
        } 

        private string get_newID()
        {            
            string currID = bao.get_newID();
            int t = Convert.ToInt32(currID) + 1;
            return t.ToString();
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}